package com.example.bootintegration.controller;

import com.example.bootintegration.service.MQRedis;
import com.example.bootintegration.service.RedisListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.async.DeferredResult;

/**
 * @author Quintoy
 * @date 2024/11/28
 */
@RestController
public class AsynController {

    @Autowired
    RedisListener redisListener;
    @Autowired
    MQRedis mqRedis;

    @GetMapping("/test_await")
    public DeferredResult testAwait() {
        DeferredResult<String> resut = new DeferredResult<>();
        redisListener.addDeferredResult("123", resut);
        return resut;
    }

    @GetMapping("/trigger")
    public void trigger() {
        // DeferredResult<String> remove = map.remove("123");
        mqRedis.send("123");

    }
}
